<?

require_once("com/borderwaitmaps/entities/BorderCrossing.php");
require_once("com/borderwaitmaps/entities/BorderCrossings.php");
require_once("com/borderwaitmaps/json/BorderCrossingParser.php");


class BorderCrossingsParser
{
	
	private $borderCrossings;

	public function BorderCrossingsParser()
	{
		$this->borderCrossings = new BorderCrossings();		
	}
	
	public function unmarshall($data)
	{
		$borderCrossingParser = new BorderCrossingParser();
		for ($index = 0; $index < sizeof($data->data); $index++) {
			$borderCrossingData = $data->data[$index];
			$borderCrossing = $borderCrossingParser->unmarshall( $borderCrossingData );
			$this->borderCrossings->addCrossing( $borderCrossing );
		}
		return $this->borderCrossings;
		
	}
	
	public function marshall( $borderCrossings )
	{
		$data;
		$data->class = "BorderCrossings";
		$list = $borderCrossings->getCrossings();
		$borderCrossingParser = new BorderCrossingParser();
		for ($index = 0; $index < sizeof($list); $index++) {
			$borderCrossing = $list[$index];
			$marshalledBorderCrossing = $borderCrossingParser->marshall( $borderCrossing );
			$data->crossings[$index] = $marshalledBorderCrossing;
		}
		return ($data);
		
	}
	
}


?>